var LeftImage;
var MiddleImage;
var RightImage;
var LeftImage_SM;
var MiddleImage_SM;
var RightImage_SM;
var tokenLeft, tokenRight, tokenMiddle;

//Copy
var Right_Title, Left_Title, Middle_Title;
var Right_SubTitle, Left_SubTitle, Middle_SubTitle;

var NextPanel = "MiddleSMPanel";
var MovePanelNext;


//Image References - MUST BE PNG OR JPG, NO GIFS
   /////////////////////////////////////////////////////
   //******UPDATE BELOW TO ALTER IMAGES AND COPY****////
   /////////////////////////////////////////////////////
function LoadBg(sender)
{
//   sender.findName("BackgroundImage").source = "http://www.microsoft.com/global/downloads/en/PublishingImages/SLWindowPane/StageBackground_full.jpg";
}

function OnLoaded(sender, args)
{
   //Assign vars
   LeftImage = 	sender.FindName("LeftImage");
   MiddleImage = sender.FindName("MiddleImage");
   RightImage = sender.FindName("RightImage");
   LeftImage_SM = sender.FindName("LeftImage_SM");
   MiddleImage_SM = sender.FindName("MiddleImage_SM");
   RightImage_SM = sender.FindName("RightImage_SM");
   //Copy
   Right_Title = sender.FindName("Right_Title");
   Right_SubTitle = sender.FindName("Right_SubTitle");
   Left_Title = sender.FindName("Left_Title");
   Left_SubTitle = sender.FindName("Left_SubTitle");
   Middle_Title = sender.FindName("Middle_Title");
   Middle_SubTitle = sender.FindName("Middle_SubTitle");

   /////////////////////////////////////////////////////
   //******UPDATE BELOW TO ALTER IMAGES AND COPY****////
   /////////////////////////////////////////////////////
   
   // CHARACTER STRING LIMITS!
   //
   //            *_Title.Text :  17-20 (depending on letterforms)
   //         *_SubTitle.Text :  26-28 (depending on letterforms)
   //
   // Please ensure that the Title and SubTitle are short enough to remain on a single line each.


   //LeftImage Image References
   LeftImage.source = "/global/downloads/en/PublishingImages/Marketing_Images/SLWindowPane/Office2010_TRY3_L.jpg";
   LeftImage_SM.source = "/global/downloads/en/PublishingImages/Marketing_Images/SLWindowPane/Office2010_T.png";
   //Left Copy
   Left_Title.Text = "Microsoft Office 2010";
   Left_SubTitle.Text = "Free Trial";
   //Add EventListeners
   tokenLeft = LeftImage.addEventListener("MouseLeftButtonDown", PanelImageDown);
   
   //MiddleImage Image References
   MiddleImage.source = "/global/downloads/en/PublishingImages/Marketing_Images/SLWindowPane/WindowsSP2011_L.jpg";
   MiddleImage_SM.source = "/global/downloads/en/PublishingImages/Marketing_Images/SLWindowPane/Windows_SP_T.png";
   //Middle Copy
   Middle_Title.Text = "Free update";
   Middle_SubTitle.Text = "Windows Service Packs";
   
   //RightImage Image References
   RightImage.source = "/global/downloads/en/PublishingImages/Marketing_Images/SLWindowPane/IE9_orange_MAY11_L.jpg";
   RightImage_SM.source = "/global/downloads/en/PublishingImages/Marketing_Images/SLWindowPane/IE9_T.png";
   //Right Copy
   Right_Title.Text = "Free download";
   Right_SubTitle.Text = "Windows Internet Explorer 9";
   /////////////////////////////////////////////////////
   //******UPDATE ABOVE TO ALTER IMAGES AND COPY****////
   /////////////////////////////////////////////////////


   sender.findName("background").Visibility = "Visible";
   sender.findName("FadeIn").begin();
   sender.findName("Timer").begin();
}

//LINKS FOR LARGE PANELS
/////////////////////////////////////////////////////////////////////////
//******TRACKING TAGS IN CASE STATEMENT BELOW****////
/////////////////////////////////////////////////////////////////////////
function PanelImageDown(sender, args) 
{
    switch (sender.Name)
    {
        case "LeftImage":
            window.location = "http://clk.atdmt.com/MRT/go/306457896/direct/01/";
	        dcsMultiTrack("DCS.dcssip", "http://clk.atdmt.com", "DCS.dcsuri", "/MRT/go/306457896/direct/01/", "DCS.dcsqry", "", "WT.ti", "Link:Try Microsoft Office 2010 for free.", "DCSext.dsplinkid", "15-00-114LMUS004950", "WT.dl", "1", "WT.ad", "", "WT.mc_id", "", "WT.sp", "");
            break;

        case "MiddleImage":
            window.location = "http://windows.microsoft.com/en-US/windows/downloads/service-packs";
            dcsMultiTrack("DCS.dcssip", "http://windows.microsoft.com", "DCS.dcsuri", "/en-US/windows/downloads/service-packs", "DCS.dcsqry", "", "WT.ti", "Link:Check to see if you have the latest service pack for your version of Windows.", "DCSext.dsplinkid", "15-00-111SUS03716", "WT.dl", "1", "WT.ad", "", "WT.mc_id", "", "WT.sp", "");
            break;

	    case "RightImage":
	         window.location = "http://clk.atdmt.com/MRT/go/306335909/direct/01/";
	        dcsMultiTrack("DCS.dcssip", "http://clk.atdmt.com", "DCS.dcsuri", "/MRT/go/306335909/direct/01/", "DCS.dcsqry", "", "WT.ti", "Link:Download Windows Internet Explorer 9 today.", "DCSext.dsplinkid", "15-00-114LMUS004923", "WT.dl", "1", "WT.ad", "", "WT.mc_id", "", "WT.sp", "");
            break;
    }        
}


function PanelOver(sender)
{    
    //Stop the automove
    sender.findName("Timer").stop();
    var pausePanel = sender.FindName("PausePanel");
    
    switch (sender.Name)
    {
        case "LeftSMPanel":
	        sender.FindName("RightSMPanel").visibility = "Visible";
            sender.FindName("MiddleSMPanel").visibility = "Visible";
            sender.FindName("LeftImage").visibility = "Visible";
            //Add Pause
	        sender.FindName("LeftSmFadeIn").begin();
	        pausePanel.begin();
	        MovePanelNext = "MoveLeft";
	        NextPanel = "MiddleSMPanel";
	        /////////////////////////////////////////////////////////////////////////
            //******Add tracking tag here to track rollovers on left small panel****////
            /////////////////////////////////////////////////////////////////////////
            break;
        case "MiddleSMPanel":
            sender.FindName("LeftSMPanel").visibility = "Visible";
            sender.FindName("RightSMPanel").visibility = "Visible";
            sender.FindName("MiddleImage").visibility = "Visible";
            //Add Pause
            sender.FindName("MiddleSmFadeIn").begin();
            pausePanel.begin();
            MovePanelNext = "MoveMiddle";
            NextPanel = "RightSMPanel";
            /////////////////////////////////////////////////////////////////////////
            //******Add tracking tag here to track rollovers on left small panel****////
            /////////////////////////////////////////////////////////////////////////
            break;
        case "RightSMPanel":
            sender.FindName("LeftSMPanel").visibility = "Visible";
            sender.FindName("MiddleSMPanel").visibility = "Visible";
            sender.FindName("RightImage").visibility = "Visible";
            //Add Pause
            sender.FindName("RightSmFadeIn").begin();
            pausePanel.begin();
            MovePanelNext = "MoveRight";
            NextPanel = "LeftSMPanel";
            /////////////////////////////////////////////////////////////////////////
            //******Add tracking tag here to track rollovers on left small panel****////
            /////////////////////////////////////////////////////////////////////////
            break;
    }

}

function PanelDown(sender)
{    
    //Stop the automove
    sender.findName("Timer").stop();
    sender.FindName("PausePanel").stop();
    
    switch (sender.Name)
    {
        case "LeftSMPanel":
            sender.FindName("RightSMPanel").visibility = "Visible";
            sender.FindName("MiddleSMPanel").visibility = "Visible";
            sender.FindName("LeftImage").visibility = "Visible";
            //Add Pause
            sender.FindName("MoveLeft").begin();
            MovePanelNext = "MoveLeft";
            NextPanel = "MiddleSMPanel";
            /////////////////////////////////////////////////////////////////////////
            //******Add tracking tag here to track clicks on left small panel****////
            /////////////////////////////////////////////////////////////////////////
            break;
        case "MiddleSMPanel":
            sender.FindName("LeftSMPanel").visibility = "Visible";
            sender.FindName("RightSMPanel").visibility = "Visible";
            sender.FindName("MiddleImage").visibility = "Visible";
            //Add Pause
            sender.FindName("MoveMiddle").begin();
            MovePanelNext = "MoveMiddle";
            NextPanel = "RightSMPanel";
            /////////////////////////////////////////////////////////////////////////
            //******Add tracking tag here to track clicks on left small panel****////
            /////////////////////////////////////////////////////////////////////////
            break;
        case "RightSMPanel":
            sender.FindName("LeftSMPanel").visibility = "Visible";
            sender.FindName("MiddleSMPanel").visibility = "Visible";
            sender.FindName("RightImage").visibility = "Visible";
            //Add Pause
            sender.FindName("MoveRight").begin();
            MovePanelNext = "MoveRight";
            NextPanel = "LeftSMPanel";
            /////////////////////////////////////////////////////////////////////////
            //******Add tracking tag here to track clicks on left small panel****////
            /////////////////////////////////////////////////////////////////////////
            break;
    }

}

function MovePanel(sender)
{
    sender.FindName("PausePanel").stop();
    sender.FindName(MovePanelNext).begin();	
}

function PanelMoveEnd(sender, args)
{
    switch (sender.Name)
    {
        case "MoveLeft":
            sender.FindName("LeftSMPanel").visibility = "Collapsed";
            sender.FindName("MiddleImage").visibility = "Collapsed";sender.FindName("LeftImage").visibility = "Visible";
            sender.FindName("RightImage").visibility = "Collapsed";

            sender.FindName("RightSMPanel").visibility = "Visible";
            sender.FindName("MiddleSMPanel").visibility = "Visible";

            //Add EventListeners
            tokenLeft = sender.FindName("LeftImage").addEventListener("MouseLeftButtonDown", PanelImageDown);
            //Remove EventListeners
            sender.findName("MiddleImage").removeEventListener("MouseLeftButtonDown", tokenMiddle);
            sender.findName("RightImage").removeEventListener("MouseLeftButtonDown", tokenRight);
            break;
        case "MoveMiddle":
            sender.FindName("MiddleSMPanel").visibility = "Collapsed";
            sender.FindName("RightImage").visibility = "Collapsed";
            sender.FindName("LeftImage").visibility = "Collapsed";sender.FindName("MiddleImage").visibility = "Visible";
            sender.FindName("LeftSMPanel").visibility = "Visible";
            sender.FindName("RightSMPanel").visibility = "Visible";

            //Add EventListeners
            tokenMiddle = sender.FindName("MiddleImage").addEventListener("MouseLeftButtonDown", PanelImageDown);
            //Remove EventListeners
            sender.findName("LeftImage").removeEventListener("MouseLeftButtonDown", tokenLeft);
            sender.findName("RightImage").removeEventListener("MouseLeftButtonDown", tokenRight);
            break;
        case "MoveRight":
            sender.FindName("MiddleImage").visibility = "Collapsed";
            sender.FindName("LeftImage").visibility = "Collapsed";
            sender.FindName("RightSMPanel").visibility = "Collapsed";
            sender.FindName("LeftSMPanel").visibility = "Visible";sender.FindName("RightImage").visibility = "Visible";
            sender.FindName("MiddleSMPanel").visibility = "Visible";
            //Add EventListeners
            tokenRight = sender.FindName("RightImage").addEventListener("MouseLeftButtonDown", PanelImageDown);
            //Remove EventListeners
            sender.findName("LeftImage").removeEventListener("MouseLeftButtonDown", tokenLeft);
            sender.findName("MiddleImage").removeEventListener("MouseLeftButtonDown", tokenMiddle);
            break;
    }

}

function Next(sender, args)
{
    PanelOver(sender.findName(NextPanel));
    sender.findName("Timer").begin();
}

function SmallPanelOver(sender, args)
{
	var panel = sender.name.replace("SMPanel","");
	sender.findName(panel+"SmFadeIn").begin();
}
function SmallPanelLeave(sender, args)
{
	var panel = sender.name.replace("SMPanel","");
	sender.findName(panel+"SmFadeOut").begin();
}





 


